package com.me.study.jdk8.lambda;

import com.me.common.util.SleepUtil;

import java.util.Objects;
import java.util.StringJoiner;

/**
 * 苹果实体类
 *
 * @author ME
 * @date   2019/4/29
 */
public class Apple {

    /**种类*/
    private String name;
    /**颜色*/
    private String color;
    /**重量，单位：g*/
    private int weight;
    /**产地*/
    private String origin ;

    public Apple() {
    }

    public Apple(String name, String color, int weight, String origin) {
        this.name = name;
        this.color = color;
        this.weight = weight;
        this.origin = origin;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public String getOrigin() {
        return origin;
    }

    public void setOrigin(String origin) {
        this.origin = origin;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Apple apple = (Apple) o;
        return weight == apple.weight && Objects.equals(name, apple.name) && Objects.equals(color, apple.color) && Objects.equals(origin, apple.origin);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, color, weight, origin);
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", Apple.class.getSimpleName() + "[", "]")
                .add("kind='" + name + "'")
                .add("color='" + color + "'")
                .add("weight=" + weight)
                .add("origin='" + origin + "'")
                .toString();
    }
}
